﻿#include "subwindow_image.h"
#include "ui_subwindow_image.h"

int SubWindow_Image::m_num = 0;

SubWindow_Image::SubWindow_Image(QGraphicsScene* scene,QWidget *parent) :
    QMdiSubWindow(parent),
    ui(new Ui::SubWindow_Image)
{
    ui->setupUi(this);
    m_pScene = scene;
    m_pScene->setBackgroundBrush(Qt::white);
    m_pView = new CanvasDesktop(m_pScene);
    m_pView->setRenderHint(QPainter::Antialiasing);
    m_pView->setCacheMode(QGraphicsView::CacheBackground);
    m_pView->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
    m_pView->setDragMode(QGraphicsView::ScrollHandDrag);
    m_pView->setStyleSheet("QGraphicsView{background-color:gray;}");
    this->setWidget(m_pView);
    m_num += 1;
    this->setWindowTitle(QStringLiteral("新建画布%1").arg(m_num));
}

SubWindow_Image::~SubWindow_Image()
{
    delete ui;
}

CanvasDesktop* SubWindow_Image::GetView()
{
    return m_pView;
}

QGraphicsScene* SubWindow_Image::GetScene()
{
    return m_pScene;
}
